//
//  SY_Par_Attendance_TableViewCell.m
//  FaceRecognition
//
//  Created by zz on 17/7/19.
//  Copyright © 2017年 Sylar. All rights reserved.
//

#import "SY_Par_Attendance_TableViewCell.h"


@interface SY_Par_Attendance_TableViewCell()

@property (nonatomic, strong) UILabel *classLabel;
@property (nonatomic, strong) UILabel *stateLabel;

@end

@implementation SY_Par_Attendance_TableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        CGFloat rate = SCREENWIDTH / 375;
        
        _classLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 * rate , 0, 345 / 2 * rate, 44)];
        _stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_classLabel.frame), 0, 345 / 2 * rate, 44)];
        
        _classLabel.font = [UIFont systemFontOfSize:15];
        _stateLabel.font = [UIFont systemFontOfSize:15];
        
        _classLabel.textColor = [UIColor colorWithHexString:@"#3b3b3b"];
        _stateLabel.textColor = [UIColor colorWithHexString:@"#3b3b3b"];
        
        _classLabel.textAlignment = NSTextAlignmentCenter;
        _stateLabel.textAlignment = NSTextAlignmentCenter;
        
        [self.contentView addSubview:_classLabel];
        [self.contentView addSubview:_stateLabel];
        
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(15, 43.5, SCREENWIDTH - 15, 0.5)];
        lineView.backgroundColor = [UIColor colorWithHexString:@"#dedede"];
        [self.contentView addSubview:lineView];
        
        self.contentView.backgroundColor  = [UIColor whiteColor];
    }
    
    return self;
}

- (void)setModel:(FR_Attendance_Model *)model {
    
    _model = model;
    
    if (_arrival == -1) { //考勤数据
        
        _classLabel.text = model.date;
        
        if (model.arrival == 1) {
            
            _stateLabel.textColor = [UIColor colorWithHexString:@"#3b3b3b"];
        }else if (model.arrival == 4) { //正常 显示灰色
        
            _stateLabel.textColor = [UIColor colorWithHexString:@"#999999"];
            
        }else {
            
            _stateLabel.textColor = [UIColor colorWithHexString:@"#f55f5f"];
        }
        
        NSString *stateStr;
        
        switch (model.arrival) {
            case 0:
                stateStr = @"旷课";
                break;
            case 1:
                stateStr = @"正常";
                break;
            case 2:
                stateStr = @"迟到";
                break;
            case 3:
                stateStr = @"请假";
                break;
            case 4:
                stateStr = @"休息";
                break;
            default:
                break;
        }
        
        _stateLabel.text = stateStr;
        
    }else if (_arrival == 0) { //旷课
    
        _classLabel.text = model.studentname;
        _stateLabel.text = model.date;

        
    }else if (_arrival == 2) { //迟到
    
        _classLabel.text = model.studentname;
        _stateLabel.text = model.date;
    }
    

}

@end
